<!-- HTML header for doxygen 1.8.3.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.4"/>
<title>CUB: block_discontinuity.cuh Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-38890655-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">CUB
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.4 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Groups</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d583f216f1aafe19404e836b0c097ad2.html">cub</a></li><li class="navelem"><a class="el" href="dir_011e1c944d88f71be72e1e24a5fda7cf.html">block</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">block_discontinuity.cuh</div>  </div>
</div><!--header-->
<div class="contents">
<a href="block__discontinuity_8cuh.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/******************************************************************************</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * Copyright (c) 2011, Duane Merrill.  All rights reserved.</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> * Copyright (c) 2011-2013, NVIDIA CORPORATION.  All rights reserved.</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * </span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> * Redistribution and use in source and binary forms, with or without</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> * modification, are permitted provided that the following conditions are met:</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment"> *     * Redistributions of source code must retain the above copyright</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment"> *       notice, this list of conditions and the following disclaimer.</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment"> *     * Redistributions in binary form must reproduce the above copyright</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment"> *       notice, this list of conditions and the following disclaimer in the</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"> *       documentation and/or other materials provided with the distribution.</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment"> *     * Neither the name of the NVIDIA CORPORATION nor the</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment"> *       names of its contributors may be used to endorse or promote products</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"> *       derived from this software without specific prior written permission.</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment"> * </span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot; AND</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment"> * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment"> * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</span></div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment"> * DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY</span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment"> * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES</span></div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment"> * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="comment"> * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</span></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="comment"> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span></div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="comment"> * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="comment"> * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="comment"> ******************************************************************************/</span></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="preprocessor">#include &quot;../util_type.cuh&quot;</span></div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="preprocessor">#include &quot;../util_namespace.cuh&quot;</span></div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;CUB_NS_PREFIX</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="keyword">namespace </span>cub {</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;<span class="keyword">template</span> &lt;</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;    <span class="keyword">typename</span>    T,</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    <span class="keywordtype">int</span>         BLOCK_THREADS&gt;</div>
<div class="line"><a name="l00097"></a><span class="lineno"><a class="code" href="classcub_1_1_block_discontinuity.html">   97</a></span>&#160;<span class="keyword">class </span><a class="code" href="classcub_1_1_block_discontinuity.html" title="The BlockDiscontinuity class provides collective methods for flagging discontinuities within an order...">BlockDiscontinuity</a></div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;{</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;    <span class="comment">/******************************************************************************</span></div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;<span class="comment">     * Type definitions</span></div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;<span class="comment">     ******************************************************************************/</span></div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;    <span class="keyword">typedef</span> T _TempStorage[BLOCK_THREADS];</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;    <span class="comment">/******************************************************************************</span></div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;<span class="comment">     * Utility methods</span></div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;<span class="comment">     ******************************************************************************/</span></div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;    __device__ __forceinline__ _TempStorage&amp; PrivateStorage()</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;    {</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;        __shared__ _TempStorage private_storage;</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;        <span class="keywordflow">return</span> private_storage;</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    }</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    template &lt;typename FlagOp, bool HAS_PARAM = BinaryOpHasIdxParam&lt;T, FlagOp&gt;::HAS_PARAM&gt;</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;    <span class="keyword">struct </span>ApplyOp</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;    {</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;        <span class="comment">// Apply flag operator</span></div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;        <span class="keyword">static</span> __device__ __forceinline__ <span class="keywordtype">bool</span> Flag(FlagOp flag_op, <span class="keyword">const</span> T &amp;a, <span class="keyword">const</span> T &amp;b, <span class="keywordtype">int</span> idx)</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;        {</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;            <span class="keywordflow">return</span> flag_op(a, b, idx);</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;        }</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;    };</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;    <span class="keyword">template</span> &lt;<span class="keyword">typename</span> FlagOp&gt;</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;    <span class="keyword">struct </span>ApplyOp&lt;FlagOp, false&gt;</div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;    {</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;        <span class="comment">// Apply flag operator</span></div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;        <span class="keyword">static</span> __device__ __forceinline__ <span class="keywordtype">bool</span> Flag(FlagOp flag_op, <span class="keyword">const</span> T &amp;a, <span class="keyword">const</span> T &amp;b, <span class="keywordtype">int</span> idx)</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;        {</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;            <span class="keywordflow">return</span> flag_op(a, b);</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;        }</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;    };</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;    <span class="comment">/******************************************************************************</span></div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;<span class="comment">     * Thread fields</span></div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;<span class="comment">     ******************************************************************************/</span></div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;</div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;    _TempStorage &amp;temp_storage;</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;    <span class="keywordtype">int</span> linear_tid;</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;</div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;</div>
<div class="line"><a name="l00158"></a><span class="lineno"><a class="code" href="structcub_1_1_block_discontinuity_1_1_temp_storage.html">  158</a></span>&#160;    <span class="keyword">struct </span><a class="code" href="structcub_1_1_block_discontinuity_1_1_temp_storage.html" title="The operations exposed by BlockDiscontinuity require a temporary memory allocation of this nested typ...">TempStorage</a> : <a class="code" href="structcub_1_1_uninitialized.html" title="A storage-backing wrapper that allows types with non-trivial constructors to be aliased in unions...">Uninitialized</a>&lt;_TempStorage&gt; {};</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;    <span class="comment">/******************************************************************/</span></div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;</div>
<div class="line"><a name="l00169"></a><span class="lineno"><a class="code" href="classcub_1_1_block_discontinuity.html#a5bee18d5e423a26fd3fefa741832ad8c">  169</a></span>&#160;    __device__ __forceinline__ <a class="code" href="classcub_1_1_block_discontinuity.html#a5bee18d5e423a26fd3fefa741832ad8c" title="Collective constructor for 1D thread blocks using a private static allocation of shared memory as tem...">BlockDiscontinuity</a>()</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;    :</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;        temp_storage(PrivateStorage()),</div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;        linear_tid(threadIdx.x)</div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;    {}</div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;</div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;</div>
<div class="line"><a name="l00179"></a><span class="lineno"><a class="code" href="classcub_1_1_block_discontinuity.html#a3f5c69462af0c9609f845e474842cfb2">  179</a></span>&#160;    __device__ __forceinline__ <a class="code" href="classcub_1_1_block_discontinuity.html#a3f5c69462af0c9609f845e474842cfb2" title="Collective constructor for 1D thread blocks using the specified memory allocation as temporary storag...">BlockDiscontinuity</a>(</div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;        <a class="code" href="structcub_1_1_block_discontinuity_1_1_temp_storage.html" title="The operations exposed by BlockDiscontinuity require a temporary memory allocation of this nested typ...">TempStorage</a> &amp;temp_storage)  </div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;    :</div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;        temp_storage(temp_storage.Alias()),</div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;        linear_tid(threadIdx.x)</div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;    {}</div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;</div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;</div>
<div class="line"><a name="l00190"></a><span class="lineno"><a class="code" href="classcub_1_1_block_discontinuity.html#a4c99f418ce99535494ae1c309f58f0ac">  190</a></span>&#160;    __device__ __forceinline__ <a class="code" href="classcub_1_1_block_discontinuity.html#a4c99f418ce99535494ae1c309f58f0ac" title="Collective constructor using a private static allocation of shared memory as temporary storage...">BlockDiscontinuity</a>(</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;        <span class="keywordtype">int</span> linear_tid)             </div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;    :</div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;        temp_storage(PrivateStorage()),</div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;        linear_tid(linear_tid)</div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;    {}</div>
<div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;</div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;</div>
<div class="line"><a name="l00201"></a><span class="lineno"><a class="code" href="classcub_1_1_block_discontinuity.html#a0edc454bf6d30810b3b086ec77ed4e11">  201</a></span>&#160;    __device__ __forceinline__ <a class="code" href="classcub_1_1_block_discontinuity.html#a0edc454bf6d30810b3b086ec77ed4e11" title="Collective constructor using the specified memory allocation as temporary storage. Each thread is identified using the supplied linear thread identifier. ">BlockDiscontinuity</a>(</div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;        <a class="code" href="structcub_1_1_block_discontinuity_1_1_temp_storage.html" title="The operations exposed by BlockDiscontinuity require a temporary memory allocation of this nested typ...">TempStorage</a> &amp;temp_storage,  </div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;        <span class="keywordtype">int</span> linear_tid)             </div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;    :</div>
<div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;        temp_storage(temp_storage.Alias()),</div>
<div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;        linear_tid(linear_tid)</div>
<div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;    {}</div>
<div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;</div>
<div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;</div>
<div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;</div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;    <span class="comment">/******************************************************************/</span></div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;</div>
<div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;</div>
<div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;    <span class="keyword">template</span> &lt;</div>
<div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;        <span class="keywordtype">int</span>             ITEMS_PER_THREAD,</div>
<div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;        <span class="keyword">typename</span>        FlagT,</div>
<div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;        <span class="keyword">typename</span>        FlagOp&gt;</div>
<div class="line"><a name="l00271"></a><span class="lineno"><a class="code" href="classcub_1_1_block_discontinuity.html#afabe7f18d7098e7d0f149696bec17186">  271</a></span>&#160;    __device__ __forceinline__ <span class="keywordtype">void</span> <a class="code" href="classcub_1_1_block_discontinuity.html#afabe7f18d7098e7d0f149696bec17186" title="Sets head flags indicating discontinuities between items partitioned across the thread block...">FlagHeads</a>(</div>
<div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160;        FlagT           (&amp;head_flags)[ITEMS_PER_THREAD],    </div>
<div class="line"><a name="l00273"></a><span class="lineno">  273</span>&#160;        T               (&amp;input)[ITEMS_PER_THREAD],         </div>
<div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160;        FlagOp          flag_op)                            </div>
<div class="line"><a name="l00275"></a><span class="lineno">  275</span>&#160;    {</div>
<div class="line"><a name="l00276"></a><span class="lineno">  276</span>&#160;        <span class="comment">// Share last item</span></div>
<div class="line"><a name="l00277"></a><span class="lineno">  277</span>&#160;        temp_storage[linear_tid] = input[ITEMS_PER_THREAD - 1];</div>
<div class="line"><a name="l00278"></a><span class="lineno">  278</span>&#160;</div>
<div class="line"><a name="l00279"></a><span class="lineno">  279</span>&#160;        __syncthreads();</div>
<div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;</div>
<div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;        <span class="comment">// Set flag for first item</span></div>
<div class="line"><a name="l00282"></a><span class="lineno">  282</span>&#160;        head_flags[0] = (linear_tid == 0) ?</div>
<div class="line"><a name="l00283"></a><span class="lineno">  283</span>&#160;            1 :                                 <span class="comment">// First thread</span></div>
<div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;            ApplyOp&lt;FlagOp&gt;::Flag(</div>
<div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;                flag_op,</div>
<div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;                temp_storage[linear_tid - 1],</div>
<div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;                input[0],</div>
<div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160;                linear_tid * ITEMS_PER_THREAD);</div>
<div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;</div>
<div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160;        <span class="comment">// Set head_flags for remaining items</span></div>
<div class="line"><a name="l00291"></a><span class="lineno">  291</span>&#160;<span class="preprocessor">        #pragma unroll</span></div>
<div class="line"><a name="l00292"></a><span class="lineno">  292</span>&#160;<span class="preprocessor"></span>        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> ITEM = 1; ITEM &lt; ITEMS_PER_THREAD; ITEM++)</div>
<div class="line"><a name="l00293"></a><span class="lineno">  293</span>&#160;        {</div>
<div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160;            head_flags[ITEM] = ApplyOp&lt;FlagOp&gt;::Flag(</div>
<div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;                flag_op,</div>
<div class="line"><a name="l00296"></a><span class="lineno">  296</span>&#160;                input[ITEM - 1],</div>
<div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;                input[ITEM],</div>
<div class="line"><a name="l00298"></a><span class="lineno">  298</span>&#160;                (linear_tid * ITEMS_PER_THREAD) + ITEM);</div>
<div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;        }</div>
<div class="line"><a name="l00300"></a><span class="lineno">  300</span>&#160;    }</div>
<div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;</div>
<div class="line"><a name="l00302"></a><span class="lineno">  302</span>&#160;</div>
<div class="line"><a name="l00357"></a><span class="lineno">  357</span>&#160;    <span class="keyword">template</span> &lt;</div>
<div class="line"><a name="l00358"></a><span class="lineno">  358</span>&#160;        <span class="keywordtype">int</span>             ITEMS_PER_THREAD,</div>
<div class="line"><a name="l00359"></a><span class="lineno">  359</span>&#160;        <span class="keyword">typename</span>        FlagT,</div>
<div class="line"><a name="l00360"></a><span class="lineno">  360</span>&#160;        <span class="keyword">typename</span>        FlagOp&gt;</div>
<div class="line"><a name="l00361"></a><span class="lineno"><a class="code" href="classcub_1_1_block_discontinuity.html#ac1d38030af4f9228613f78207e64a314">  361</a></span>&#160;    __device__ __forceinline__ <span class="keywordtype">void</span> <a class="code" href="classcub_1_1_block_discontinuity.html#ac1d38030af4f9228613f78207e64a314" title="Sets head flags indicating discontinuities between items partitioned across the thread block...">FlagHeads</a>(</div>
<div class="line"><a name="l00362"></a><span class="lineno">  362</span>&#160;        FlagT           (&amp;head_flags)[ITEMS_PER_THREAD],    </div>
<div class="line"><a name="l00363"></a><span class="lineno">  363</span>&#160;        T               (&amp;input)[ITEMS_PER_THREAD],         </div>
<div class="line"><a name="l00364"></a><span class="lineno">  364</span>&#160;        FlagOp          flag_op,                            </div>
<div class="line"><a name="l00365"></a><span class="lineno">  365</span>&#160;        T               tile_predecessor_item)                   </div>
<div class="line"><a name="l00366"></a><span class="lineno">  366</span>&#160;    {</div>
<div class="line"><a name="l00367"></a><span class="lineno">  367</span>&#160;        <span class="comment">// Share last item</span></div>
<div class="line"><a name="l00368"></a><span class="lineno">  368</span>&#160;        temp_storage[linear_tid] = input[ITEMS_PER_THREAD - 1];</div>
<div class="line"><a name="l00369"></a><span class="lineno">  369</span>&#160;</div>
<div class="line"><a name="l00370"></a><span class="lineno">  370</span>&#160;        __syncthreads();</div>
<div class="line"><a name="l00371"></a><span class="lineno">  371</span>&#160;</div>
<div class="line"><a name="l00372"></a><span class="lineno">  372</span>&#160;        <span class="comment">// Set flag for first item</span></div>
<div class="line"><a name="l00373"></a><span class="lineno">  373</span>&#160;        <span class="keywordtype">int</span> predecessor = (linear_tid == 0) ?</div>
<div class="line"><a name="l00374"></a><span class="lineno">  374</span>&#160;            tile_predecessor_item :              <span class="comment">// First thread</span></div>
<div class="line"><a name="l00375"></a><span class="lineno">  375</span>&#160;            temp_storage[linear_tid - 1];</div>
<div class="line"><a name="l00376"></a><span class="lineno">  376</span>&#160;</div>
<div class="line"><a name="l00377"></a><span class="lineno">  377</span>&#160;        head_flags[0] = ApplyOp&lt;FlagOp&gt;::Flag(</div>
<div class="line"><a name="l00378"></a><span class="lineno">  378</span>&#160;            flag_op,</div>
<div class="line"><a name="l00379"></a><span class="lineno">  379</span>&#160;            predecessor,</div>
<div class="line"><a name="l00380"></a><span class="lineno">  380</span>&#160;            input[0],</div>
<div class="line"><a name="l00381"></a><span class="lineno">  381</span>&#160;            linear_tid * ITEMS_PER_THREAD);</div>
<div class="line"><a name="l00382"></a><span class="lineno">  382</span>&#160;</div>
<div class="line"><a name="l00383"></a><span class="lineno">  383</span>&#160;        <span class="comment">// Set flag for remaining items</span></div>
<div class="line"><a name="l00384"></a><span class="lineno">  384</span>&#160;<span class="preprocessor">        #pragma unroll</span></div>
<div class="line"><a name="l00385"></a><span class="lineno">  385</span>&#160;<span class="preprocessor"></span>        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> ITEM = 1; ITEM &lt; ITEMS_PER_THREAD; ITEM++)</div>
<div class="line"><a name="l00386"></a><span class="lineno">  386</span>&#160;        {</div>
<div class="line"><a name="l00387"></a><span class="lineno">  387</span>&#160;            head_flags[ITEM] = ApplyOp&lt;FlagOp&gt;::Flag(</div>
<div class="line"><a name="l00388"></a><span class="lineno">  388</span>&#160;                flag_op,</div>
<div class="line"><a name="l00389"></a><span class="lineno">  389</span>&#160;                input[ITEM - 1],</div>
<div class="line"><a name="l00390"></a><span class="lineno">  390</span>&#160;                input[ITEM],</div>
<div class="line"><a name="l00391"></a><span class="lineno">  391</span>&#160;                (linear_tid * ITEMS_PER_THREAD) + ITEM);</div>
<div class="line"><a name="l00392"></a><span class="lineno">  392</span>&#160;        }</div>
<div class="line"><a name="l00393"></a><span class="lineno">  393</span>&#160;    }</div>
<div class="line"><a name="l00394"></a><span class="lineno">  394</span>&#160;</div>
<div class="line"><a name="l00395"></a><span class="lineno">  395</span>&#160;</div>
<div class="line"><a name="l00397"></a><span class="lineno">  397</span>&#160;    <span class="comment">/******************************************************************/</span></div>
<div class="line"><a name="l00401"></a><span class="lineno">  401</span>&#160;</div>
<div class="line"><a name="l00402"></a><span class="lineno">  402</span>&#160;</div>
<div class="line"><a name="l00452"></a><span class="lineno">  452</span>&#160;    <span class="keyword">template</span> &lt;</div>
<div class="line"><a name="l00453"></a><span class="lineno">  453</span>&#160;        <span class="keywordtype">int</span>             ITEMS_PER_THREAD,</div>
<div class="line"><a name="l00454"></a><span class="lineno">  454</span>&#160;        <span class="keyword">typename</span>        FlagT,</div>
<div class="line"><a name="l00455"></a><span class="lineno">  455</span>&#160;        <span class="keyword">typename</span>        FlagOp&gt;</div>
<div class="line"><a name="l00456"></a><span class="lineno"><a class="code" href="classcub_1_1_block_discontinuity.html#acf705e15934ba04c556e5860a2853652">  456</a></span>&#160;    __device__ __forceinline__ <span class="keywordtype">void</span> <a class="code" href="classcub_1_1_block_discontinuity.html#acf705e15934ba04c556e5860a2853652" title="Sets tail flags indicating discontinuities between items partitioned across the thread block...">FlagTails</a>(</div>
<div class="line"><a name="l00457"></a><span class="lineno">  457</span>&#160;        FlagT           (&amp;tail_flags)[ITEMS_PER_THREAD],    </div>
<div class="line"><a name="l00458"></a><span class="lineno">  458</span>&#160;        T               (&amp;input)[ITEMS_PER_THREAD],         </div>
<div class="line"><a name="l00459"></a><span class="lineno">  459</span>&#160;        FlagOp          flag_op)                            </div>
<div class="line"><a name="l00460"></a><span class="lineno">  460</span>&#160;    {</div>
<div class="line"><a name="l00461"></a><span class="lineno">  461</span>&#160;        <span class="comment">// Share first item</span></div>
<div class="line"><a name="l00462"></a><span class="lineno">  462</span>&#160;        temp_storage[linear_tid] = input[0];</div>
<div class="line"><a name="l00463"></a><span class="lineno">  463</span>&#160;</div>
<div class="line"><a name="l00464"></a><span class="lineno">  464</span>&#160;        __syncthreads();</div>
<div class="line"><a name="l00465"></a><span class="lineno">  465</span>&#160;</div>
<div class="line"><a name="l00466"></a><span class="lineno">  466</span>&#160;        <span class="comment">// Set flag for last item</span></div>
<div class="line"><a name="l00467"></a><span class="lineno">  467</span>&#160;        tail_flags[ITEMS_PER_THREAD - 1] = (linear_tid == BLOCK_THREADS - 1) ?</div>
<div class="line"><a name="l00468"></a><span class="lineno">  468</span>&#160;            1 :                             <span class="comment">// Last thread</span></div>
<div class="line"><a name="l00469"></a><span class="lineno">  469</span>&#160;            ApplyOp&lt;FlagOp&gt;::Flag(</div>
<div class="line"><a name="l00470"></a><span class="lineno">  470</span>&#160;                flag_op,</div>
<div class="line"><a name="l00471"></a><span class="lineno">  471</span>&#160;                input[ITEMS_PER_THREAD - 1],</div>
<div class="line"><a name="l00472"></a><span class="lineno">  472</span>&#160;                temp_storage[linear_tid + 1],</div>
<div class="line"><a name="l00473"></a><span class="lineno">  473</span>&#160;                (linear_tid * ITEMS_PER_THREAD) + (ITEMS_PER_THREAD - 1));</div>
<div class="line"><a name="l00474"></a><span class="lineno">  474</span>&#160;</div>
<div class="line"><a name="l00475"></a><span class="lineno">  475</span>&#160;        <span class="comment">// Set flags for remaining items</span></div>
<div class="line"><a name="l00476"></a><span class="lineno">  476</span>&#160;<span class="preprocessor">        #pragma unroll</span></div>
<div class="line"><a name="l00477"></a><span class="lineno">  477</span>&#160;<span class="preprocessor"></span>        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> ITEM = 0; ITEM &lt; ITEMS_PER_THREAD - 1; ITEM++)</div>
<div class="line"><a name="l00478"></a><span class="lineno">  478</span>&#160;        {</div>
<div class="line"><a name="l00479"></a><span class="lineno">  479</span>&#160;            tail_flags[ITEM] = ApplyOp&lt;FlagOp&gt;::Flag(</div>
<div class="line"><a name="l00480"></a><span class="lineno">  480</span>&#160;                flag_op,</div>
<div class="line"><a name="l00481"></a><span class="lineno">  481</span>&#160;                input[ITEM],</div>
<div class="line"><a name="l00482"></a><span class="lineno">  482</span>&#160;                input[ITEM + 1],</div>
<div class="line"><a name="l00483"></a><span class="lineno">  483</span>&#160;                (linear_tid * ITEMS_PER_THREAD) + ITEM);</div>
<div class="line"><a name="l00484"></a><span class="lineno">  484</span>&#160;        }</div>
<div class="line"><a name="l00485"></a><span class="lineno">  485</span>&#160;    }</div>
<div class="line"><a name="l00486"></a><span class="lineno">  486</span>&#160;</div>
<div class="line"><a name="l00487"></a><span class="lineno">  487</span>&#160;</div>
<div class="line"><a name="l00543"></a><span class="lineno">  543</span>&#160;    <span class="keyword">template</span> &lt;</div>
<div class="line"><a name="l00544"></a><span class="lineno">  544</span>&#160;        <span class="keywordtype">int</span>             ITEMS_PER_THREAD,</div>
<div class="line"><a name="l00545"></a><span class="lineno">  545</span>&#160;        <span class="keyword">typename</span>        FlagT,</div>
<div class="line"><a name="l00546"></a><span class="lineno">  546</span>&#160;        <span class="keyword">typename</span>        FlagOp&gt;</div>
<div class="line"><a name="l00547"></a><span class="lineno"><a class="code" href="classcub_1_1_block_discontinuity.html#ad80f6195b0366d7f88180dc349043179">  547</a></span>&#160;    __device__ __forceinline__ <span class="keywordtype">void</span> <a class="code" href="classcub_1_1_block_discontinuity.html#ad80f6195b0366d7f88180dc349043179" title="Sets tail flags indicating discontinuities between items partitioned across the thread block...">FlagTails</a>(</div>
<div class="line"><a name="l00548"></a><span class="lineno">  548</span>&#160;        FlagT           (&amp;tail_flags)[ITEMS_PER_THREAD],    </div>
<div class="line"><a name="l00549"></a><span class="lineno">  549</span>&#160;        T               (&amp;input)[ITEMS_PER_THREAD],         </div>
<div class="line"><a name="l00550"></a><span class="lineno">  550</span>&#160;        FlagOp          flag_op,                            </div>
<div class="line"><a name="l00551"></a><span class="lineno">  551</span>&#160;        T               tile_successor_item)                   </div>
<div class="line"><a name="l00552"></a><span class="lineno">  552</span>&#160;    {</div>
<div class="line"><a name="l00553"></a><span class="lineno">  553</span>&#160;        <span class="comment">// Share first item</span></div>
<div class="line"><a name="l00554"></a><span class="lineno">  554</span>&#160;        temp_storage[linear_tid] = input[0];</div>
<div class="line"><a name="l00555"></a><span class="lineno">  555</span>&#160;</div>
<div class="line"><a name="l00556"></a><span class="lineno">  556</span>&#160;        __syncthreads();</div>
<div class="line"><a name="l00557"></a><span class="lineno">  557</span>&#160;</div>
<div class="line"><a name="l00558"></a><span class="lineno">  558</span>&#160;        <span class="comment">// Set flag for last item</span></div>
<div class="line"><a name="l00559"></a><span class="lineno">  559</span>&#160;        <span class="keywordtype">int</span> successor_item = (linear_tid == BLOCK_THREADS - 1) ?</div>
<div class="line"><a name="l00560"></a><span class="lineno">  560</span>&#160;            tile_successor_item :              <span class="comment">// Last thread</span></div>
<div class="line"><a name="l00561"></a><span class="lineno">  561</span>&#160;            temp_storage[linear_tid + 1];</div>
<div class="line"><a name="l00562"></a><span class="lineno">  562</span>&#160;</div>
<div class="line"><a name="l00563"></a><span class="lineno">  563</span>&#160;        tail_flags[ITEMS_PER_THREAD - 1] = ApplyOp&lt;FlagOp&gt;::Flag(</div>
<div class="line"><a name="l00564"></a><span class="lineno">  564</span>&#160;            flag_op,</div>
<div class="line"><a name="l00565"></a><span class="lineno">  565</span>&#160;            input[ITEMS_PER_THREAD - 1],</div>
<div class="line"><a name="l00566"></a><span class="lineno">  566</span>&#160;            successor_item,</div>
<div class="line"><a name="l00567"></a><span class="lineno">  567</span>&#160;            (linear_tid * ITEMS_PER_THREAD) + (ITEMS_PER_THREAD - 1));</div>
<div class="line"><a name="l00568"></a><span class="lineno">  568</span>&#160;</div>
<div class="line"><a name="l00569"></a><span class="lineno">  569</span>&#160;        <span class="comment">// Set flags for remaining items</span></div>
<div class="line"><a name="l00570"></a><span class="lineno">  570</span>&#160;<span class="preprocessor">        #pragma unroll</span></div>
<div class="line"><a name="l00571"></a><span class="lineno">  571</span>&#160;<span class="preprocessor"></span>        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> ITEM = 0; ITEM &lt; ITEMS_PER_THREAD - 1; ITEM++)</div>
<div class="line"><a name="l00572"></a><span class="lineno">  572</span>&#160;        {</div>
<div class="line"><a name="l00573"></a><span class="lineno">  573</span>&#160;            tail_flags[ITEM] = ApplyOp&lt;FlagOp&gt;::Flag(</div>
<div class="line"><a name="l00574"></a><span class="lineno">  574</span>&#160;                flag_op,</div>
<div class="line"><a name="l00575"></a><span class="lineno">  575</span>&#160;                input[ITEM],</div>
<div class="line"><a name="l00576"></a><span class="lineno">  576</span>&#160;                input[ITEM + 1],</div>
<div class="line"><a name="l00577"></a><span class="lineno">  577</span>&#160;                (linear_tid * ITEMS_PER_THREAD) + ITEM);</div>
<div class="line"><a name="l00578"></a><span class="lineno">  578</span>&#160;        }</div>
<div class="line"><a name="l00579"></a><span class="lineno">  579</span>&#160;    }</div>
<div class="line"><a name="l00580"></a><span class="lineno">  580</span>&#160;</div>
<div class="line"><a name="l00582"></a><span class="lineno">  582</span>&#160;</div>
<div class="line"><a name="l00583"></a><span class="lineno">  583</span>&#160;};</div>
<div class="line"><a name="l00584"></a><span class="lineno">  584</span>&#160;</div>
<div class="line"><a name="l00585"></a><span class="lineno">  585</span>&#160;</div>
<div class="line"><a name="l00586"></a><span class="lineno">  586</span>&#160;}               <span class="comment">// CUB namespace</span></div>
<div class="line"><a name="l00587"></a><span class="lineno">  587</span>&#160;CUB_NS_POSTFIX  <span class="comment">// Optional outer namespace(s)</span></div>
</div><!-- fragment --></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.3.1-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Aug 23 2013 17:31:09 for CUB by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.4
<br>
&copy; 2013 NVIDIA Corporation
</small></address>
</body>
</html>
